<template>
	<div class="diglog-info streetEdit projectDialog">
		<el-dialog title="编辑" :visible.sync="dialogVisible" size='small'>
			<el-tabs>
				<el-tab-pane label="项目信息">
					<el-form :model="dataAll" :rules="rules" ref="dataAll" label-width="0" class="demo-ruleForm">
						<div v-if="dataAll" class="zui-noFloat">
							<el-row :gutter="80">
								<el-col :span="12">
									<el-form-item prop="buildArea">
										<div class="content">
											<my-tooltip text="有条件建设区面积"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.buildArea" placeholder="请输入有条件建设区面积"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="hookArea">
										<div class="content">
											<my-tooltip text="增减挂钩指标面积"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.hookArea" placeholder="请输入增减挂钩指标面积"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="yearArea">
										<div class="content">
											<my-tooltip text="年度指标面积"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.yearArea" placeholder="请输入年度指标面积"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="approvalArea">
										<div class="content">
											<my-tooltip text="取得用地批文面积"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.approvalArea" placeholder="请输入取得用地批文面积"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="approvalNum">
										<div class="content">
											<my-tooltip text="批文号"></my-tooltip>
											<div class="desc-input">
												<el-input v-model="dataAll.approvalNum" placeholder="请输入批文号"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="cardArea">
										<div class="content">
											<my-tooltip text="土地证面积"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.cardArea" placeholder="请输入土地证面积"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="landNature">
										<div class="content">
											<my-tooltip text="用地性质"></my-tooltip>
											<div class="desc-input">
												<el-input v-model="dataAll.landNature" placeholder="请输入用地性质"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="landNum">
										<div class="content">
											<my-tooltip text="土地证证号"></my-tooltip>
											<div class="desc-input">
												<el-input v-model="dataAll.landNum" placeholder="请输入土地证证号"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item prop="landLife">
										<div class="content">
											<my-tooltip text="用地年限"></my-tooltip>
											<div class="desc-input">
												<el-input v-model.number="dataAll.landLife" placeholder="请输入用地年限"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="24">
									<el-form-item prop="extent">
										<div class="content">
											<my-tooltip text="宗地四至描述"></my-tooltip>
											<div class="desc-input">
												<el-input v-model="dataAll.extent" type="textarea" placeholder="请输入宗地四至描述"></el-input>
											</div>
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<div style="text-align:left; margin-left:100px;">
								<el-button type="primary" @click="upate('dataAll')" style="width:130px">保存</el-button>
								<el-button @click="dialogVisible = false" style="width:130px;margin-left:20px">取消</el-button>
							</div>
						</div>
					</el-form>
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
	</div>
</template>
<script>
	export default {
		props: ['showDialogId'],
		created() {
			this.ajax({
				url: 'tProjectLand/selectProjectLandById',
				data: {
					id: this.showDialogId
				}
			}).then(data => {
				this.dataAll.pId=this.showDialogId;
				if(data.length){
					this.dataAll = data[0]
				}
			})
		},
		mounted() {

		},
		watch: {
			dialogVisible(val) {
				this.$emit('update:showDialog', val)
			}
		},
		data() {
			var check = (rule, value, callback) => {
				if(!value) {
					callback()
				} else if(!Number.isInteger(value)) {
					callback(new Error('请输入数值'))
				} else {
					callback()
				}
			}
			return {
				dialogVisible: true, //弹出框隐藏显示
				dataAll: {
					
				},
				rules: {
					buildArea: [{
						validator: check,
						type: 'number',
						message: '有条件建设区面积必须为数字值'
					}],
					approvalArea: [{
						validator: check,
						type: 'number',
						message: '取得批文面积必须为数字值'
					}],
					landLife: [{
						validator: check,
						type: 'number',
						message: '用地年限必须为数字值'
					}],
					cardArea: [{
						validator: check,
						type: 'number',
						message: '土地证面积必须为数字值'
					}],
					yearArea: [{
						validator: check,
						type: 'number',
						message: '年度指标面积必须为数字值'
					}],
					hookArea: [{
						validator: check,
						type: 'number',
						message: '增减挂钩指标面积必须为数字值'
					}]
				},
			}
		},
		methods: {
			show(row) {
				this.dialogVisible = !this.dialogVisible
			},
			upate(formName) {
				this.$refs[formName].validate((valid) => {
					if(valid) {
						this.ajax({
							url: 'tProjectLand/editProjectLand',
							type: 'post',
							data: this.dataAll,
						}).then(data => {
							/*向上传递修改成功的信息*/
							this.eventBus.$emit('streetUpdate')
							this.dialogVisible = false
						})
					}
				});
			}
		},
		components: {

		}
	}
</script>
<style lang="less">
	.streetEdit .el-form-item__error {
		top: 35px;
		left: 100px;
	}
	
	.streetEdit .el-form-item {
		min-height: 50px;
		margin-bottom: 5px;
	}
</style>
<style scoped lang="less">
	.zui-noFloat .el-col {
		float: none;
		display: inline-block;
		margin-right: -4px;
		vertical-align: top;
	}
	
	.projectDialog .desc-input {
		width: 70%;
		float: left;
	}
</style>